home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BBS in a Box 7
/
BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso
/
Files
/
Tele
/
C
/
Comet2.1.3.cpt
/
3270XCMD
/
TNSendCmd.c
< prev
next >
Wrap
Text File
|
1989-08-23
|
2KB
|
97 lines
/* TNSendCmd.c -- XCMD to send a command to TN3270 through the TN3270 driver
copyright 1989 Cornell University
*/
#include <Types.h>
#include <Memory.h>
#include <Devices.h>
#include <HyperXCmd.h>
#include <Errors.h>
#include <String.h>
#include "TNdrvr.h"
pascal void debugger() extern 0xA9FF;
pascal void TNSendCmd(hycp)
XCmdPtr hycp;
{
CntrlParam drvpb;
long * args;
Str255 pstr;
if (hycp->paramCount != 3) {
sethand(&hycp->returnValue, "TNSendCmd TNID,class,entry: need 3 arguments");
return;
}
HLock((Handle) hycp->params[0]);
HLock((Handle) hycp->params[1]);
ZeroToPas(hycp, *hycp->params[0], (StringPtr) &pstr[0]);
drvpb.ioCRefNum = (short) StrToNum(hycp, (Str31 *) &pstr[0]);
drvpb.csCode = HTN_SENDCMD;
args = (long *) &drvpb.csParam[0];
*args++ = * (long *) hycp->params[1];
*args++ = * (long *) hycp->params[2];
/* pass the string *s to the drvr to pass on to TN3270 */
PBControl((ParmBlkPtr) &drvpb, (Boolean) 0);
if (drvpb.ioResult) {
/* connect call failed */
switch (drvpb.ioResult) {
case HTNR_NOTN: {
sethand(&hycp->returnValue, "TN is not running");
break;
}
case HTNR_ACTIVE: {
sethand(&hycp->returnValue, "TN not opened");
break;
}
case HTNR_OPEN: {
sethand(&hycp->returnValue, "TN has no connection");
break;
}
case HTNR_CLASS: {
sethand(&hycp->returnValue, "Invalid Command Class");
break;
}
case HTNR_ENTRY: {
sethand(&hycp->returnValue, "Invalid Command Entry");
break;
}
case badUnitErr: {
sethand(&hycp->returnValue, "TNID is incorrect");
break;
}
default: {
sethand(&hycp->returnValue, "Unknown error");
break;
}
}
}
HUnlock((Handle) hycp->params[0]);
HUnlock((Handle) hycp->params[1]);
}
sethand(thand, str)
Handle * thand;
char * str;
{
if (*thand == NULL) {
*thand = NewHandle((Size) 0);
}
SetHandleSize(*thand, (long) (strlen(str) + 1));
strcpy(**thand, str);
}
#include <XCmdGlue.inc.c>